package niit.game;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.ImageView;

public class Splashsreeen extends Activity implements Runnable {

	Thread mThread;
	Runnable mRunable;
	boolean active = true;
	int mTime = 300;
	ImageView logo;

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.splashscreen);
		logo = (ImageView) findViewById(R.id.iv_spfashscreen);
		logo.setBackgroundResource(R.drawable.logo);
	}

	@Override
	protected void onResume() {
		active = true;
		mTime = 300;
		super.onResume();
	}

	@Override
	public void onWindowFocusChanged(boolean hasFocus) {
		if (mThread == null) {
			mThread = new Thread(this);
			mThread.start();
		}
		super.onWindowFocusChanged(hasFocus);
	}

	public void run() {
		try {
			while (active && mTime > 0) {
				mTime -= 10;
				mThread.sleep(300);
				

			}

		} catch (Exception e) {
			
		} finally {
			
			startActivity(new Intent(getBaseContext(),
					WorldOfWarplanesActivity.class));
			
			finish();
		}

	}
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if(event.getAction()==MotionEvent.ACTION_DOWN){
			active=false;
		}
		return super.onTouchEvent(event);
	}

}
